Ext.define("App.controller.Article", {
	extend: "Ext.app.Controller",
	requires: ["Ext.MessageBox"],
	config: {
		refs: {
			articleCard: "#articleCard",
            articleList: "#articleList",
			articleInfo: "#articleInfo"
        },
		
		control: {
            articleList: {
            	itemtap: "onArticleListItemTap"
            }
		}
	},
	
	
	onArticleListItemTap: function(list, idx, el, record){
		var articleStore = Ext.getStore('Article');
		var id = record.get('id');

		articleStore.clearFilter();
		
		articleStore.setProxy({
            type: "jsonp",
            url: "http://www.51inews.com/inewsServer/findArticleInfoVoPage.action?id=" + id,
            callbackKey: 'callback',
            reader: {
                type: "json",
                rootProperty: "root"
            }
        });
		articleStore.load();
		if (!this.articleInfo) {
			this.articleInfo = Ext.widget('articleInfo');
		}
		this.articleInfo.config.title = record.get('title');
		this.getArticleCard().push(this.articleInfo);
		this.articleInfo.setStore(articleStore);
	}
	
});